package com.ruoyi.web.controller.biz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.biz.domain.BizGoodsCategoryStrategy;
import com.ruoyi.biz.service.IBizGoodsCategoryStrategyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商品类别价格策略信息Controller
 * 
 * @author tds
 * @date 2022-11-10
 */
@RestController
@RequestMapping("/biz/goodsCategofyStrategy")
public class BizGoodsCategoryStrategyController extends BaseController
{
    @Autowired
    private IBizGoodsCategoryStrategyService bizGoodsCategoryStrategyService;

    /**
     * 查询商品类别价格策略信息列表
     */
    @PreAuthorize("@ss.hasPermi('biz:goodsCategofyStrategy:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizGoodsCategoryStrategy bizGoodsCategoryStrategy)
    {
        startPage();
        List<BizGoodsCategoryStrategy> list = bizGoodsCategoryStrategyService.selectBizGoodsCategoryStrategyList(bizGoodsCategoryStrategy);
        return getDataTable(list);
    }

    /**
     * 导出商品类别价格策略信息列表
     */
    @PreAuthorize("@ss.hasPermi('biz:goodsCategofyStrategy:export')")
    @Log(title = "商品类别价格策略信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizGoodsCategoryStrategy bizGoodsCategoryStrategy)
    {
        List<BizGoodsCategoryStrategy> list = bizGoodsCategoryStrategyService.selectBizGoodsCategoryStrategyList(bizGoodsCategoryStrategy);
        ExcelUtil<BizGoodsCategoryStrategy> util = new ExcelUtil<BizGoodsCategoryStrategy>(BizGoodsCategoryStrategy.class);
        util.exportExcel(response, list, "商品类别价格策略信息数据");
    }

    /**
     * 获取商品类别价格策略信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('biz:goodsCategofyStrategy:query')")
    @GetMapping(value = "/{strategyId}")
    public AjaxResult getInfo(@PathVariable("strategyId") Long strategyId)
    {
        return success(bizGoodsCategoryStrategyService.selectBizGoodsCategoryStrategyByStrategyId(strategyId));
    }

    /**
     * 新增商品类别价格策略信息
     */
    @PreAuthorize("@ss.hasPermi('biz:goodsCategofyStrategy:add')")
    @Log(title = "商品类别价格策略信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizGoodsCategoryStrategy bizGoodsCategoryStrategy)
    {
        return toAjax(bizGoodsCategoryStrategyService.insertBizGoodsCategoryStrategy(bizGoodsCategoryStrategy));
    }

    /**
     * 修改商品类别价格策略信息
     */
    @PreAuthorize("@ss.hasPermi('biz:goodsCategofyStrategy:edit')")
    @Log(title = "商品类别价格策略信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizGoodsCategoryStrategy bizGoodsCategoryStrategy)
    {
        return toAjax(bizGoodsCategoryStrategyService.updateBizGoodsCategoryStrategy(bizGoodsCategoryStrategy));
    }

    /**
     * 删除商品类别价格策略信息
     */
    @PreAuthorize("@ss.hasPermi('biz:goodsCategofyStrategy:remove')")
    @Log(title = "商品类别价格策略信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{strategyIds}")
    public AjaxResult remove(@PathVariable Long[] strategyIds)
    {
        return toAjax(bizGoodsCategoryStrategyService.deleteBizGoodsCategoryStrategyByStrategyIds(strategyIds));
    }
}
